UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'PTihSc5H3J02+0045Sw0xW8CDkkX+NKGiq4wOaWo+CI='
WHERE
key_id = 'ea7d326f085c53e8f86e9b7524ccd29b202df43e7868e73a90c294a8847b614b'
AND (
token = 'PTihSc5H3J02+0045Sw0xW8CDkkX+NKGiq4wOaWo+CI='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)